package com.lotus.vigil.repository;

import com.lotus.vigil.model.DeviceFaultRecords;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.time.LocalDateTime;
import java.util.List;

public interface FaultRecordRepository extends JpaRepository<DeviceFaultRecords,Long> {



    @Query("SELECT d FROM DeviceFaultRecords d " +
            "WHERE d.occurTime BETWEEN :startTime AND :endTime " +
            "ORDER BY d.faultId, d.opType ASC" )
    List<DeviceFaultRecords> findEventsInRange(
            @Param("startTime") LocalDateTime startTime,
            @Param("endTime") LocalDateTime endTime
    );
}
